<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSqlRelationalDelegate Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSqlRelationalDelegate Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1><p>The QSqlRelationalDelegate class provides a delegate that is
used to display and edit data from a <a href="qsqlrelationaltablemodel.html">QSqlRelationalTableModel</a>.
<a href="#details">More...</a></p>

<p>Inherits <a href="qitemdelegate.html">QItemDelegate</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsqlrelationaldelegate.html#QSqlRelationalDelegate">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QWidget <b><a href="qsqlrelationaldelegate.html#createEditor">createEditor</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>, QStyleOptionViewItem&#160;<i>option</i>, QModelIndex&#160;<i>index</i>)</li><li><div class="fn" /><b><a href="qsqlrelationaldelegate.html#setEditorData">setEditorData</a></b> (<i>self</i>, QWidget&#160;<i>editor</i>, QModelIndex&#160;<i>index</i>)</li><li><div class="fn" /><b><a href="qsqlrelationaldelegate.html#setModelData">setModelData</a></b> (<i>self</i>, QWidget&#160;<i>editor</i>, QAbstractItemModel&#160;<i>model</i>, QModelIndex&#160;<i>index</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSqlRelationalDelegate class provides a delegate that is
used to display and edit data from a <a href="qsqlrelationaltablemodel.html">QSqlRelationalTableModel</a>.</p>
<p>Unlike the default delegate, QSqlRelationalDelegate provides a
combobox for fields that are foreign keys into other tables. To use
the class, simply call <a href="qabstractitemview.html#setItemDelegate">QAbstractItemView.setItemDelegate</a>()
on the view with an instance of QSqlRelationalDelegate:</p>
<pre class="cpp">
     <span class="type"><a href="qtableview.html">QTableView</a></span> <span class="operator">*</span>view <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtableview.html">QTableView</a></span>;
     view<span class="operator">-</span><span class="operator">&gt;</span>setModel(model);
     view<span class="operator">-</span><span class="operator">&gt;</span>setItemDelegate(<span class="keyword">new</span> <span class="type">QSqlRelationalDelegate</span>(view));
</pre>
<p>The <a href="sql-relationaltablemodel.html">Relational Table
Model</a> example (shown below) illustrates how to use
QSqlRelationalDelegate in conjunction with <a href="qsqlrelationaltablemodel.html">QSqlRelationalTableModel</a> to
provide tables with foreign key support.</p>
<p class="centerAlign"><img src="images/relationaltable.png" /></p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSqlRelationalDelegate" />QSqlRelationalDelegate.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsqlrelationaldelegate.html">QSqlRelationalDelegate</a> object
with the given <i>parent</i>.</p>


<h3 class="fn"><a name="createEditor" /><a href="qwidget.html">QWidget</a> QSqlRelationalDelegate.createEditor (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a>&#160;<i>option</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Reimplemented from <a href="qabstractitemdelegate.html#createEditor">QAbstractItemDelegate.createEditor</a>().</p>


<h3 class="fn"><a name="setEditorData" />QSqlRelationalDelegate.setEditorData (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>editor</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemdelegate.html#setEditorData">QAbstractItemDelegate.setEditorData</a>().</p>


<h3 class="fn"><a name="setModelData" />QSqlRelationalDelegate.setModelData (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>editor</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>&#160;<i>model</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemdelegate.html#setModelData">QAbstractItemDelegate.setModelData</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>